module vga_display #(
	parameter	H_DISP	= 10'd640,		    //分辨率(行)
	parameter	V_DISP	= 10'd480		    //分辨率(列)
)
(
	input					vga_clk,		//VGA驱动时钟
	input					sys_rst_n,		//复位信号
	
	input			[12:0]	pixel_xpos,		//像素点横坐标
	input			[12:0]	pixel_ypos,		//像素点纵坐标
	output      reg	[11:0]	pixel_data		//像素点数据
);

	localparam		BLACK		=12'h000;
	localparam		WHITE		=12'hFFF;

	localparam		H_DIVIDE_32 = H_DISP / 32;
	localparam		V_DIVIDE_24 = V_DISP / 24;
	
	wire						cnt_h;
	wire						cnt_v;
	
	assign cnt_h = ((pixel_xpos - pixel_xpos % H_DIVIDE_32) / H_DIVIDE_32) % 2;
	assign cnt_v = ((pixel_ypos - pixel_ypos % V_DIVIDE_24) / V_DIVIDE_24) % 2;

	//根据当前像素点坐标指定当前像素点颜色数据，在屏幕上显示黑白方格
	always @ (posedge vga_clk or negedge sys_rst_n) begin
		if(!sys_rst_n) pixel_data <= 12'd0;
		else begin
			if(cnt_h == 1'b0) begin
				if(cnt_v == 1'b0) pixel_data <= BLACK;
				else pixel_data <= WHITE;
			end
			else begin
				if(cnt_v == 1'b0) pixel_data <= WHITE;
				else pixel_data <= BLACK;
			end
		end
	end

endmodule 